package com.zhangjie.serviceverificationcode.controller;

import com.zhangjie.internalcommon.dto.ResponseResult;
import com.zhangjie.internalcommon.response.NumberCodeResponse;
import net.sf.json.JSONObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: zj
 * @Date: 2024/1/19 - 01 - 19 - 18:02
 * @Description: com.zhangjie.serviceverificationcode.controller
 * @version: 1.0
 */
@RestController
public class NumberCodeController {

    @GetMapping("/numberCode/{size}")
    public ResponseResult numberCode(@PathVariable("size") int size){

        System.out.println("size:" + size);
        // 生成验证码
        double mathRandom = (Math.random()*9 + 1) * Math.pow(10,size-1);
        System.out.println(mathRandom);
        int resultInt = (int)(mathRandom);
        System.out.println("generator src code : "+resultInt);

        NumberCodeResponse response = new NumberCodeResponse();
        response.setNumberCode(resultInt);

        return ResponseResult.success(response);
    }

}
